# StartTCL: n
#
# PickPocket v0.42 #
####################

namespace eval vor {
#
variable voldir "extra/PickPocket"
#
variable VERSION 0.4
#
if { ! [ file exists $voldir ] } {file mkdir $voldir}
proc vol { from to } {
variable voldir
set mdata [GetEntry $to]
switch $mdata {
6846 { if {([GetQuestStatus $from 2206] == 3 )} {AddItem $from 7675}}
6909 { if {([GetQuestStatus $from 2242] == 3 )} {AddItem $from 7737}}
6494 { if {([GetQuestStatus $from 1858] == 3 )} {AddItem $from 7208}}
6497 { if {([GetQuestStatus $from 1886] == 3 )} {AddItem $from 7231}}
7051 { if {([GetQuestStatus $from 2539] == 3 )} {AddItem $from 7923}}
6188 { if {([GetQuestStatus $from 8234] == 3 )} {AddItem $from 19775}}
8766 { if {([GetQuestStatus $from 8235] == 3 )} {AddItem $from 20023}}
6768 { if {([GetQuestStatus $from 8236] == 3 )} {AddItem $from 20022}}
5719 { if {([GetQuestStatus $from 8236] == 3 )} {AddItem $from 20022}}
7287 { if {([GetQuestStatus $from 2478] == 3 )} {AddItem $from 8072}}
default { }
}

set Classe [GetClass $from]
set to [GetSelection $from]
set plevel [GetLevel $from]
set PName [GetName $from]
set got [GetObjectType $to]
set currenttime [clock seconds]
set lastvol 0
set skill 1
if {([file exists "$voldir/$PName"] == 1) } { set tfile [open "$voldir/$PName" r]
set lastvol [gets $tfile]
set skill [gets $tfile]
close $tfile }
if { [GetObjectType $to] == 3 } {
set Ttype [GetScpValue "creatures.scp" "creature [GetEntry $to]" "type"]
set TName [GetScpValue "creatures.scp" "creature [GetEntry $to]" "name"]
if {$Ttype==7} {
set diff [expr $currenttime - $lastvol]
set wait [expr 600-$diff]
if { $diff < 600 } { Say $from 0 "|cff008000 i need wait $wait seconds" }
if {$diff >600} {
set clevel [GetLevel $to]
if {$clevel< 10} {
set itemlist "118 2589 2570"
set ichance 10}
if {$clevel< 60} {
set itemlist "118 2589 2570"
set ichance 10}
if { $clevel >= $plevel} {
set ldiff [expr ($clevel-$plevel)]
set ratio [expr (($clevel*$skill)/($ldiff+1)*2.0)]
puts ">>>>>>>>>>>>$ratio" }
if { $plevel >$clevel} {
set ldiff [expr ($plevel-$clevel)]
set ratio [expr (($clevel*$skill)/$ldiff*10.0)]
puts "ratio=$ratio"
}
set rnd [expr {int(rand()*$ratio*2)}]
puts "random money $rnd "
set max [expr ($plevel*5)]
puts "max skill $max"
if {$rnd < $max} {
set Tadd [open "$voldir/$PName" w]
set skill [expr $skill+1]
if {$skill >= $max } {set skill $max }
puts $Tadd $currenttime
puts $Tadd $skill
close $Tadd
}
if {$rnd>=$max} {
set form [expr {int(rand()*1000)} ]
set chance [expr ($form +$skill)]
set mchance [expr (1000- $ichance*10)]
puts "player chance to get item = $ichance %"
puts "player random procent without skill [expr ($form)/(10*1)] %"
puts "player random procent with skill [expr ($chance)/(10*1)] %"
if {$chance >= $mchance } {
set item [lindex $itemlist [expr {int(rand()*[llength $itemlist])}]]
AddItem $from $item
set itname [GetScpValue "items.scp" "item $item" "name"]
Say $from 0 "|cffffff00 Ich bekam $rnd geld und $itname von dem Mob"
}
ChangeMoney $from $rnd
set Tadd [open "$voldir/$PName" w]
puts $Tadd $currenttime
puts $Tadd $skill
close $Tadd
if {$chance < $mchance } {Say $from 0 "|cffffff00 Ich bekam $rnd Geld von dem Mob"}
Say $to 0 "Ich fuehle mich etwas komisch, OMG mir wurden $rnd bronze gestohlen!"
} else {
Say $from 0 "|cffff0000 ich vermisse meine Hacke...mein Skill ist jetzt $skill"
}
}
}
if {$Ttype !=7} { Say $from 0 "|cFFF0002F Nichts zum stehlen" } }
if { [GetObjectType $to] != 3 } { set VLevel [GetLevel $to]
set diff [expr $currenttime - $lastvol]
set wait [expr 600-$diff]
if { $diff < 600 } { Say $from 0 "|cff008000 ich muss $wait Sekunden warten" }
if {$diff >600} {
set clevel [GetLevel $to]
if { $clevel >=$plevel} {
set ldiff [expr ($clevel-$plevel)]
set ratio [expr (($clevel*$skill)/($ldiff+1)*1.0)]
puts "$ratio" }
if { $plevel >$clevel} {
set ldiff [expr ($plevel-$clevel)]
set ratio [expr (($clevel*$skill)/$ldiff*10.0)]
puts " ratio=$ratio"
}
set rnd [expr {int(rand()*$ratio*2)}]
puts "random money $rnd "
set max [expr ($plevel*5)]
puts "max skill $max"
if {$rnd < $max} {
set Tadd [open "$voldir/$PName" w]
set skill [expr $skill+1]
puts $Tadd $currenttime
puts $Tadd $skill
close $Tadd
}
if {$rnd>=$max} {
if {[ChangeMoney $to -$rnd] == 1} { ChangeMoney $from $rnd
set Tadd [open "$voldir/$PName" w]
set skill [expr ($skill+1)]
puts $Tadd $currenttime
puts $Tadd $skill
Say $to 0 "Ich verlor $rnd bronze..."
} else {
Say $from 0 "|cffff0000 Ich vermisse meine Hacke...mein skill ist jetzt $skill"
}
}
}
}
}
}
